package com.spartez.farhorizons.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.gwtext.client.core.Margins;
import com.gwtext.client.core.RegionPosition;
import com.gwtext.client.widgets.Panel;
import com.gwtext.client.widgets.Viewport;
import com.gwtext.client.widgets.layout.BorderLayout;
import com.gwtext.client.widgets.layout.BorderLayoutData;
import com.gwtext.client.widgets.layout.FitLayout;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class FarHorizons implements EntryPoint {
	/**
	 * The message displayed to the user when the server cannot be reached or
	 * returns an error.
	 */
	private static final String SERVER_ERROR = "An error occurred while "
			+ "attempting to contact the server. Please check your network "
			+ "connection and try again.";

	/**
	 * Create a remote service proxy to talk to the server-side Greeting service.
	 */
	public static final GreetingServiceAsync greetingService = GWT
			.create(GreetingService.class);
	
	public static final DataService dataService = new DataService();

	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad() {
         Panel panel = new Panel();  
         panel.setBorder(false);  
         panel.setLayout(new FitLayout());
         
         Panel borderPanel = new Panel();  
         borderPanel.setLayout(new BorderLayout());

         //add north panel  
         borderPanel.add(new NavPanel(), new BorderLayoutData(RegionPosition.NORTH));  

         //add south panel  

         BorderLayoutData sysInfoData = new BorderLayoutData(RegionPosition.SOUTH);  
         sysInfoData.setMinSize(100);  
         sysInfoData.setMaxSize(200);  
         sysInfoData.setMargins(new Margins(0, 0, 0, 0));  
         sysInfoData.setSplit(true);  
         borderPanel.add(new SysInfoPanel(), sysInfoData);  

         //add east panel  

//         BorderLayoutData ordersData = new BorderLayoutData(RegionPosition.EAST);  
//         ordersData.setSplit(true);  
//         ordersData.setMinSize(175);  
//         ordersData.setMaxSize(400);  
//         ordersData.setMargins(new Margins(0, 0, 5, 0));  

//         borderPanel.add(new OrdersPanel(), ordersData);  

         BorderLayoutData reportsData = new BorderLayoutData(RegionPosition.WEST);  
         reportsData.setSplit(true);  
         reportsData.setMinSize(175);  
         reportsData.setMaxSize(400);
         reportsData.setMargins(new Margins(0, 5, 0, 0));  
         borderPanel.add(new ReportsPanel(), reportsData);  

         borderPanel.add(new MapPanel(), new BorderLayoutData(RegionPosition.CENTER));  

         panel.add(borderPanel);  

         Viewport viewport = new Viewport(panel);
         
         dataService.loadData();
	}
	
}
